home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $IBM_TO_MAC < prev    next >
Encoding:
Text File  |  1993-09-19  |  1.6 KB  |  64 lines  |  [TEXT/KEEN]

  1. # $IBM_TO_MAC: translate, sending results to new file.
  2. # New file name: is all lowercase version of the original
  3. # name - if the name of the file you'll be translating
  4. # has no uppercase characters, uncomment the line
  5. #    "## newname = "_" newname # if no uppercase"
  6. # below or modify as you wish.
  7. # Translation: the input record separator RS is set
  8. # to a line feed ("\012"). The output separator remains
  9. # a carriage return ("\015"), so all line feeds are replaced by
  10. # carriage returns. If you have additional characters to strip,
  11. # uncomment and modify the "gsub" call below.
  12. # Input typically from "MFS selected files", output to new
  13. # files with similar names and same locations, with a
  14. # summary to stdout.
  15.  
  16. BEGIN {
  17.     u = "abcdefghijklmnopqrstuvwxyz"
  18.     U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  19.     RS = "\012"
  20.     outfile = ""
  21.     }
  22.  
  23. FNR == 1 {
  24.     beep(0)
  25.     if (outfile != "")
  26.         {
  27.         close(outfile)
  28.         namearray[++numnames] = outfile
  29.         }
  30.     n = split(FILENAME, names, ":")
  31.     if (match(names[n], /;/))
  32.         newnamet = substr(names[n], 1, RSTART-1)
  33.     else
  34.         newnamet = names[n]
  35.     m = length(newnamet)
  36.     newname = ""
  37.     for (i = 1; i <= m; ++i)
  38.         {
  39.         if (ind = index(U, substr(newnamet, i, 1)))
  40.             newname = newname substr(u, ind, 1);
  41.         else
  42.             newname = newname substr(newnamet, i, 1)
  43.         }
  44.     ## newname = "_" newname # if no uppercase
  45.     outfile = names[1]
  46.     for (i = 2; i < n; ++i)
  47.         outfile = outfile ":" names[i]
  48.     ##outfile = outfile ":" "untitled folder"
  49.     outfile = outfile ":" newname
  50.     }
  51.  
  52.     {
  53.     ## gsub(/["\0"]/, "") # strip "reg exp", here a NULL.
  54.     print $0 > outfile
  55.     }
  56.  
  57. END {
  58.     namearray[++numnames] = outfile
  59.     print "translated files:"
  60.     for (i = 1; i <= numnames; ++i)
  61.         print namearray[i]
  62.     }
  63.  
  64.